﻿@model SkResult<Order>
@using (Html.BeginForm())
{
    <div class="modal-body">
        @if (Model.Status)
        {
            <div>
                <p>
                    您确定要取消该订单吗？取消订单后，不能恢复。</p>
                <p>
                    <strong>请选择取消订单的理由：</strong></p>
                <p>
                    <select id="cancelReason" name="reason">
                        <option value="我不想买了">我不想买了</option>
                        <option value="信息填写错误，重新拍">信息填写错误，重新拍</option>
                        <option value="卖家缺货">卖家缺货</option>
                        <option value="同城见面交易">同城见面交易</option>
                        <option value="其他原因">其他原因</option>
                    </select>
                </p>
            </div>
        }
        else
        {
            <div class="status-box status-box-warm-error">
                <div class="status-icon">
                    <div class="row-fluid">
                        <div class="span2">
                            <i class="icon-remove-sign icon-3x"></i>
                        </div>
                        <div class="span10">
                            <strong>@Model.Message</strong></div>
                    </div>
                </div>
            </div>
        }
    </div>
    <div class="modal-footer">
        <p id="message" class="pull-left color-red">
        </p>
        <a class="btn" href="#" data-dismiss="modal">关闭</a>
        @if (Model.Status)
        {
            <button type="button" class="btn btn-primary" onclick="submitForm(this.form)">
                确 认</button>
        }
    </div>
}
@if (Model.Status)
{
    <script type="text/javascript">
        function submitForm(form) {
            var reason = $('#cancelReason').val();
            if (reason == "") {
                $('#message', form).css('color', 'red').html("请选择取消订单的理由！");
                return;
            }
            var param = $(form).serialize();
            $.postJSON(form.action, param, function (result) {
                if (result.Status == false) {
                    $('#message', form).css('color', 'red').html(result.Message);
                }
                else {
                    $('#message', form).css('color', 'green').html("取消订单成功！");
                }
            });
        }
    </script>
}
